<?php
namespace app\home\controller;
use think\Controller;
use app\home\model\Cate;
use think\Model;
use think\View;
use think\Request;
use think\Db;

class Usertwo extends base
{
    public function quehuo()
    {
        // echo 123;
        $qwe=model("Quehuo");
        $res=$qwe->index();
        // var_dump($res);die;
       return $this->fetch('quehuo',['info'=>$res]);
    } 
    public function del()
    {
        $id=Request::instance()->param("id");
        $user=model("Quehuo");
        $res=$user->del($id);
        if ($res) {
            echo "<script>alert('删除成功');location.href='quehuo'</script>";
        }else{
            echo "<script>alert('删除失败');location.href='quehuo'</script>";
        }

    }

    public function hongbao()
    {
        $cate=model("Quehuo");
        $res=$cate->bao();
        $this->assign(['info'=>$res]);
        return $this->fetch('hongbao');
    }
    public function hongbao_add()
    {   
        $bao_sn=$_POST['bao_sn'];
        // echo "$bao_sn";die;
        $qwe=Db::table("redbao")->where('red_id',$bao_sn)->select();
        // var_dump($qwe);die;
        if ($qwe) {
            // $post=Request::instance()->param();
            $user=model("Quehuo");
            // print_r($qwe);die;
            $res=$user->adds($qwe);
            if ($res) {
                echo "<script>alert('厉害咯红包添加成功');location.href='hongbao'</script>";
            }else{
                echo "<script>alert('对不起红包已经存在');location.href='hongbao'</script>";
            }
        }else{
            echo "<script>alert('对不起没有这个红包');location.href='hongbao'</script>";
        }
    }
    public function red_del()
    {
        $id=Request::instance()->param("id");
        $user=model("Quehuo"); 
        $res=$user->red_del($id);
        if ($res) {
            echo "<script>alert('删除成功');location.href='hongbao'</script>";
        }else{
            echo "<script>alert('删除失败');location.href='hongbao'</script>";
        }
    }

    public function tuijian()
    {
        return $this->fetch();
    }
    public function pinglun()
    {
        $qwe=model('Quehuo');
        
        $res=$qwe->modelpinglun();
    	return $this->fetch('pinglun',['info'=>$res]);
    }
    public function pinglun_del()
    {
        $id=Request::instance()->param("id");
        $user=model("Quehuo");
        $res=$user->pinglun_del($id);
        if ($res) {
            echo "<script>alert('删除成功');location.href='pinglun'</script>";
        }else{
            echo "<script>alert('删除失败');location.href='pinglun'</script>";
        }
    }

    public function genzong()
    {
        return $this->fetch();
    }

    public function money()
    {
        return $this->fetch();
    }
}